package com.kxn.multi.module.common.util;

import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * 日期工具
 */
public class DateUtil {

    /**
     * 获取指定日期的时间戳
     * @param dateStr String
     * @return 
     * @throws ParseException
     */
    public static long getDateStrTimestamp(String dateStr) throws ParseException {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = df.parse(dateStr);
        return date.getTime();
    }

    /**
     * 获取当前时间戳
     *
     * @return
     */
    public static Long getCurrentTimestamp() {
        Timestamp timestamp = Timestamp.valueOf(LocalDateTime.now());
        return timestamp.getTime();
    }
}
